Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Labels API #131

Merged
merged 3 commits into from
Jun 10, 2020
Merged

feat: Labels API #131

merged 3 commits into from
Jun 10, 2020

Conversation

vlastahajek
Copy link
Contributor

Closes #130

Added support for managing labels in general and managing labels in organization

  • CHANGELOG.md updated
  • Rebased/mergeable
  • Tests pass

@vlastahajek vlastahajek requested a review from sranka June 9, 2020 12:25
@vlastahajek vlastahajek changed the title Feat/labels feat: Labels API Jun 9, 2020
Copy link
Contributor

@sranka sranka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reason why a pointer to a slice is returned in GetLabels and Find methods, is there a need to modify the returned data?


labelName := "Active State"
props := map[string]string{"color": "33ffdd", "description": "Marks org active"}
label, err := labelsApi.CreateLabelWithName(ctx, *myorg.Id, labelName, props)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use myorg.Id, it looks better

Copy link
Contributor Author

@vlastahajek vlastahajek Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, API with string pointers as params is weird as well, it isn't?
But, CreateLabelWithName should be with objects, ids should be used in CreateLabelWithNameWithId. This is consistent with other *Apis., thanks for noticing this.

@vlastahajek
Copy link
Contributor Author

I don't understand the reason why a pointer to a slice is returned in GetLabels and Find methods, is there a need to modify the returned data?

It is simply the same type as returned from the generated API, without the necessity to create an empty slice just in case of an error. It is similar pattern as in all other *Apis.
If an error is returned from the server, the slice is nil, otherwise valid. As pointers in Go are transparently used as non-pointers when accessing member, it seems ok for use.

@vlastahajek vlastahajek merged commit c2e9c69 into influxdata:master Jun 10, 2020
@vlastahajek vlastahajek deleted the feat/labels branch June 10, 2020 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Labels API
2 participants